package com.cheng.example.atguigu.view2;

import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * java -XX:+PrintFlagsInitial
 * 元空间设置
 * -XX:MetaspaceSize=8m  -XX:MaxMetaspaceSize=8m
 *
 */
public class Client87 {

    public static void main(String[] args) {
        int i = 0;
        try {
            while (true) {
                i++;
                //增强器的意思
                Enhancer enhancer = new Enhancer();
                enhancer.setSuperclass(Client87.class);
                enhancer.setUseCache(false);
                enhancer.setCallback(new MethodInterceptor() {
                    @Override
                    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
                        return methodProxy.invokeSuper(o, args);
                    }
                });
                enhancer.create();
            }
        } catch (Exception e) {
            System.out.println("**************"+i);
            e.printStackTrace();
        }
    }

}
